﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GONES.IBLL;
using GONES.IDAL;
using GONES.Model;
using log4net;
using System.Reflection;
using GONES.Tools.Common;
using Newtonsoft.Json;

namespace GONES.BLL
{
    public class S_LogManager : IS_LogManager
    {
        protected static readonly ILog Log =
             LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
        public IS_LogDao S_LogDao;
        private readonly IUserInfo _userInfo;

        public string ErrMsg { get; set; }

        public S_LogManager(IUserInfo userinfo)
        {
            _userInfo = userinfo;
        }

        /// <summary>
        /// 根据日志ID获取日志信息
        /// </summary>
        /// <param name="id">日志ID</param>
        /// <returns>日志信息</returns>
        public S_Log Get(string id)
        {
            return S_LogDao.Get(id);
        }

        /// <summary>
        /// 获取个人的日志信息
        /// </summary>
        /// <param name="filters">获取个人操作日志信息</param>
        /// <param name="pageIndex">页数</param>
        /// <param name="pageSize">每页大小</param>
        /// <param name="recordCount">记录总数</param>
        /// <returns>个人日志列表</returns>
        public IList<S_Log> SelfList(IList<DataFilter> filters, int pageIndex, int pageSize, ref long recordCount)
        {
            string strFilter = DataOperate.GetHqlstrByExtFilter(filters, "e");
            recordCount = S_LogDao.ExecHqlResultLong("SELECT COUNT(*) FROM S_Log e where 1=1 "  +
                                               (string.IsNullOrEmpty(strFilter) ? string.Empty : " and " + strFilter));

            return S_LogDao.GetHqlList("SELECT e FROM S_Log e  where  1=1 " +
                                       (string.IsNullOrEmpty(strFilter) ? string.Empty : " and " + strFilter) +
                                       " ORDER BY e.ID DESC", (pageIndex - 1) * pageSize,
                                       pageSize);
        }

      

    }
}
